<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require_once ('../db_conn.php');
$sql="SELECT * FROM tb_ltcp1";
$a8s=$db->query($sql); //执行语句  $rs是一个结果集
$ab8s=$a8s->fetch_all(MYSQLI_BOTH);

$recc=isset($_GET['recc'])?$_GET['recc']:"";
if($recc>0)
{
$sql="select * from tb_ltcp where id=$recc";
$a9s=$db->query($sql); //执行语句  $rs是一个结果集
$ab9=$a9s->fetch_array(MYSQLI_BOTH);
}

$rec=isset($_GET['rec'])?$_GET['rec']:"";

if ($rec>0)
{
    $name=$_POST['name'];
    $typeid=$_POST['typeid'];
    $price=$_POST['price'];
    $sj=$_POST['sj'];
    $sql="update tb_ltcp set typeid='$typeid',name='$name',price='$price',sj='$sj' where id=$rec";
    
    
    $rs=$db->query($sql);
        if ($rs==FALSE)
    {
        echo "<script language='javascript' type='text/javascript'>";
        echo "alert('修改失败！');";
        echo "window.location.href='addproduct1.php'";
        echo "</script>";
    }
    else
    {
        echo "<script language='javascript' type='text/javascript'>";
        echo "alert('修改成功！');";
        echo "window.location.href='product.php'";
        echo "</script>";  
    }
    }
    
if($recc>0)
{
require ('addproduct_html1.php');
}
 else {
    require ('product.php');
 }
